﻿namespace Arbalest.Web.Tests
{
    using System;
    using System.Web.Mvc;
    using Arbalest.Models;
    using Arbalest.Web.Controllers;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class CompanyControllerTest
    {
        public TestContext TestContext { get; set; }

        [TestMethod, 
        TestCategory("CompanyController"), 
        Description("Test Index")]
        public void Index()
        {
            TestContext.WriteLine("IsNotNull test");

            // Arrange
            CompanyController controller = new CompanyController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }

        [TestMethod, TestCategory("CompanyController")]
        public void Create_HTTP_GET()
        {
            TestContext.WriteLine("IsNotNull test");

            // Arrange
            CompanyController controller = new CompanyController();

            // Act
            ViewResult result = controller.Create() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }

        [TestMethod, TestCategory("CompanyController")]
        public void Edit_HTTP_GET()
        {
            TestContext.WriteLine("IsNotNull test");

            // Arrange
            CompanyController controller = new CompanyController();
            int id = 0;

            // Act
            ViewResult result = controller.Edit(id) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }

        [TestMethod, TestCategory("CompanyController")]
        public void Delete_HTTP_GET()
        {
            TestContext.WriteLine("IsNotNull test");

            // Arrange
            CompanyController controller = new CompanyController();
            int id = 0;

            // Act
            ViewResult result = controller.Delete(id) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }

        [TestMethod, TestCategory("CompanyController")]
        public void Create_HTTP_POST()
        {
            TestContext.WriteLine("IsNotNull test");

            // Arrange
            CompanyController controller = new CompanyController();
            Company company = new Company
            {
                Id=0,
                Name = "Yummy Restaurant",
                CreatedDateTime = DateTime.Today
            };

            FormCollection collection = new FormCollection();
            collection.Add("Name", "Yummy Restaurant");
            collection.Add("CreatedDateTime", "2013-04-01");

            string expectedAction = "Index";

            // Act
            RedirectToRouteResult result = controller.Create(company, collection) as RedirectToRouteResult;

            // Assert
            Assert.AreEqual(expectedAction, result.RouteValues["action"]);
        }

        
    }
}